<template>
  <div class="box">
    <div class="top">
      <p>订单趋势图</p>
      <p class="bg"></p>
    </div>
    <div class="chart" ref="chart"></div>
  </div>
</template>

<script lang="ts" setup name="CenterBottom">
import { ref, onMounted } from 'vue'
import * as echarts from 'echarts'
let chart = ref()
onMounted(() => {
  let mychart = echarts.init(chart.value)
  mychart.setOption({
    title: {},
    lengend: {},
    tooltip: {
      show: true,
      trigger: 'axis',
      axisPointer: {
        type: 'cross',
        animation: false,
        label: {
          backgroundColor: '#505765',
        },
      },
    },
    xAxis: {
      type: 'category',
      boundaryGap: false,
      data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
      splitLine: {
        show: false,
      },
      axisLine: {
        show: true,
        lineStyle: {
          color: 'rgb(222, 242, 242)',
        },
      },
    },
    yAxis: {
      name: '(订单量)',
      nameLocation: 'middle',
      nameGap: 45,
      show: true,
      splitLine: {
        show: false,
      },
      axisLine: {
        show: true,
        lineStyle: {
          color: 'rgb(212, 242, 242)',
        },
      },
    },
    grid: {
      left: 80,
      right: 20,
      top: 20,
      bottom: 30,
    },
    series: [
      {
        type: 'line',
        data: [140, 232, 101, 264, 90, 340, 250],
        lineStyle: {
          color: 'white',
          symbol: 'none',
        },
        areaStyle: {
          color: {
            type: 'linear',
            x: 0,
            y: 0,
            x2: 0,
            y2: 1,
            colorStops: [
              {
                offset: 0,
                color: 'red', // 0% 处的颜色
              },
              {
                offset: 1,
                color: 'blue', // 100% 处的颜色
              },
            ],
            global: false, // 缺省为 false
          },
        },
        smooth: true,
      },
    ],
  })
})
</script>
<style scoped lang="scss">
.box {
  height: 100%;
  display: flex;
  flex-direction: column;
  flex: 12;
  color: rgb(255, 255, 255);
  overflow: hidden;
  .top {
    flex: 2;

    p {
      height: 50%;
      font-size: 20px;
      font-weight: blod;
    }
    .bg {
      background: url('../../images/dataScreen-title.png') no-repeat left bottom;
      background-size: 100px;
    }
  }
  .chart {
    flex: 8;
    height: 100%;
  }
}
</style>
